<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class Login extends Eloquent  {

    protected  $table ='users';
    public $primaryKey  = '_id';

    protected $fillable = array('_id','fname','lname','email','mobile','password','country','state','city','address','zip');

  //protected $TableData = DB::table('user')->get();
	public static function validation($data){

		 $rules=array(
			'_id'=>'required',
			'fname'=>'required',
			'lname'=>'required',
			'email'=>'required',
			'mobile'=>'required',
			'password'=>'required',
            );
		 $messages = array(
            'required' => 'The :attribute field is required.',
            'unique' => 'The :attribute is already exist.',
            'numeric' => 'The :attribute must be number only.',
            'email' => 'Email is not valid.'
        );

			$v=Validator::make($data,$rules,$messages);
			return $v;
	}

	// public static function InsertData($input){
	// 	//	$input['_id']='5';
	// 						$user=new User;
	// 						$user->_id=$input['_id'];	
	// 						$user->name=$input['name'];
	// 						$user->email=$input['email'];
	// 						$user->phone=$input['phone'];
	// 						$user->password=$input['password'];
	// 						$user->type=$input['type'];
	// 						$user->save();
	// 	}
	public static function ShowData($id){
		$Tdata = DB::table('user')->where('_id', '=',$id)->get();
		return $Tdata;
	}

	public static function EditData($input){
		//	$input['_id']='5';
							//$user=new User;
							$user->_id=$input['_id'];
							$user->name=$input['name'];
							$user->email=$input['email'];
							$user->phone=$input['phone'];
							$user->password=$input['password'];
							$user->type=$input['type'];
							$user->save();
		}

}
